public class Main{

    public static void main(String[] args) {
        SingleLinkedList s = new SingleLinkedList();
        System.out.print("环的入口点val: ");
        System.out.println(s.detectCycle(SingleLinkedList.createCycle(s)).val);
    }
    public static void main4(String[] args) {
        SingleLinkedList head = new SingleLinkedList();
        head.addLast(1);
        head.addLast(2);
        head.addLast(3);
        head.addLast(3);
        head.addLast(2);
        head.addLast(1);
        System.out.println(head.palindrome(head.head));
        System.out.println("=================");
        SingleLinkedList head1 = new SingleLinkedList();
        head1.addLast(1);
        head1.addLast(2);
        head1.addLast(3);
        head1.addLast(2);
        head1.addLast(1);
        System.out.println(head.palindrome(head1.head));
        System.out.println("=================");
        SingleLinkedList head2 = new SingleLinkedList();
        head2.addLast(1);
        head2.addLast(1);
        head2.addLast(9);
        head2.addLast(4);
        head2.addLast(1);
        System.out.println(head.palindrome(head2.head));

    }
    public static void main3(String[] args) {
        SingleLinkedList head = new SingleLinkedList();
        head.addLast(5);
        head.addLast(1);
        head.addLast(2);
        head.addLast(7);
        head.addLast(4);
        head.addLast(9);
        head.addLast(10);
        head.addLast(3);


        //按照6划分
        System.out.print("划分前：");
        head.display();

        System.out.print("划分后： ");
        head.partition(6);
        head.display();
    }

    public static void main2(String[] args) {
        SingleLinkedList head = new SingleLinkedList();

        head.addFirst(2);
        head.addFirst(1);
        head.addLast(3);
        head.addIndex(0,0);
        head.addIndex(4,4);

        System.out.print("反转前: ");
        head.display();
        head.reverseSingleLinkedList(head.head);
        System.out.print("反转后: ");
        head.display();
    }
    public static void main1(String[] args) {
        SingleLinkedList head = new SingleLinkedList();

        //增加
        //头插
        head.addFirst(2);
        head.addFirst(1);
        //尾插
        head.addLast(3);
        //索引插入
        head.addIndex(0,0);
        head.addIndex(4,4);
        //移除
        head.remove(3);
        //增加
        head.addIndex(3,3);
        //打印
        head.display();

        System.out.println("==================");
        head.remove(1);
        head.remove(2);
        head.remove(3);
        head.remove(4);
        //只剩下0元素
        head.addLast(0);
        head.addLast(0);
        //包含
        System.out.println(head.contains(0));
        //移除0
        head.removeAllKey(0);
        //不包含
        System.out.println(head.contains(0));
        //回收
        head.clear();
        head.display();
        }

}